package com.example.admin.service;


import com.example.admin.common.Result;
import com.example.admin.entity.ActivityRecord;
import com.example.admin.mapper.ActivityRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityRecordService {

    @Autowired
    private ActivityRecordMapper activityRecordMapper;
    public List<ActivityRecord> selectActivityRecordPage() {

      List<ActivityRecord> activityRecordList=  activityRecordMapper.selectActivityRecordPage();
        return activityRecordList;
    }

    public Result addActivityRecord(ActivityRecord activityRecord) {

      int count=  activityRecordMapper.addActivityRecord(activityRecord);
      if(count==0)
      {
          return Result.error("400","新增失败");
      }
      return Result.success("新增成功");
    }

    public Result editActivityRecord(ActivityRecord activityRecord) {

     int count=   activityRecordMapper.editActivityRecord(activityRecord);
        if(count==0)
        {
            return Result.error("400","修改失败");
        }
        return Result.success("修改成功");
    }

    public Result deleteActivityRecordById(Integer id) {

      int count=  activityRecordMapper.deleteActivityRecordById(id);
        if(count==0)
        {
            return Result.error("400","删除失败");
        }
        return Result.success("删除成功");
    }

    public List<ActivityRecord> selectActivityRecordById(Integer elderId) {
      List<ActivityRecord> activityRecordList=  activityRecordMapper.selectActivityRecordById(elderId);
      return activityRecordList;
    }
}
